package com.rollcall.wisdomroll.SQLiteDatabase;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * Created by lenovo on 2021-01-04.
 */

public class DatabaseHelper extends SQLiteOpenHelper{

    public DatabaseHelper(Context context){
        super(context,Constant.DATABASE_NAME,null,Constant.DATABASE_VERSION);
    }

    //带全部参数的构造函数，此构造函数必不可少
    public DatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }
    @Override
    public void onCreate(SQLiteDatabase db) {
        //创建数据库sql语句 并 执行
        String sql = "create table "+Constant.TABLE_NAME+"(OrderId VARCHAR(32) PRIMARY KEY ,prisonerName VARCHAR(32) NOT NULL ,creator VARCHAR(32) NOT NULL," +
                "IDCard VARCHAR(32) NOT NULL,nation VARCHAR(32) NOT NULL,sex VARCHAR(32) NOT NULL,arrestingOrgan VARCHAR(32) NOT NULL,political VARCHAR(32) NOT NULL," +
                "inStartTime VARCHAR(32) NOT NULL,operator VARCHAR(32) NOT NULL,labelID VARCHAR(32) NOT NULL,prisonerID VARCHAR(32) NOT NULL," +
                "prisonID VARCHAR(32) NOT NULL,startTime VARCHAR(32) NOT NULL,endTime VARCHAR(32) NOT NULL,operateDate VARCHAR(32) NOT NULL,labelCode VARCHAR(32) NOT NULL)";
        db.execSQL(sql);

        String sql2 = "create table "+Constant.TABLE1_NAME+"prisonerID VARCHAR(32) NOT NULL," +
                "prisonerpic VARCHAR(32) NOT NULL";
        db.execSQL(sql2);
        Log.e("fhndjfdjf","建表了吗");
    }
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
    @Override
    public void onOpen(SQLiteDatabase db) {
        super.onOpen(db);
        // TODO 每次成功打开数据库后首先被运行
    }
}
